<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        <button @click="flag=true">姓名</button>
        <button @click="flag=false">邮箱</button>
        <hr />
        <template v-if="flag">
          姓名 <input key="3" type="text" name="username" />
        </template>
        <template v-else>
          邮箱 <input key="2" type="text" name="email" />
        </template>
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      // [{ tagName: "input", name: "username", key: "1" }];
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          flag: true,
        },
      });
    </script>
  </body>
</html>
